
function HierarchyManager(name, baseUrl, url, service)
{
	this.name = name;
	this.baseUrl = baseUrl;
	this.url = url;
	this.service = service;
	try
    {
		this.xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        //this.xmlHttp = new XMLHttpRequest();
       // alert('FireFox ou IE7');
    }
	catch(e)
	{
	    try
	    {
		    this.xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	    }
	    catch(ex)
	    {
			err(ex);
		    this.xmlHttp = null;
	    }
	}	
}

HierarchyManager.prototype.ChoosePage = function (hyperlinkType,pageUri)
{
	var result;

	result = window.showModalDialog(this.url + "?filter=" + hyperlinkType + "&pageUri=" + pageUri, null, "dialogHeight: 450px; dialogWidth: 350px; edge: Raised; center: Yes; help: No; scroll:no; resizable: No; status: No;");
	
	return result;
}

HierarchyManager.prototype.GetUrl = function (nodeId)
{
	var post;
	var doc;
	var response;
	var responseDocument;
	var status;
	post = "nodeId=" + nodeId;

	this.xmlHttp.Open("POST", this.service + '/GetUrl', false);
	this.xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	this.xmlHttp.Send(post);

	doc = this.xmlHttp.responseXML;

	if (doc.parseError.errorCode != 0 || doc.xml == '')
	{
		SiteNote.Debug.error('[HierarchyManager] Unable to execute request: ' + this.xmlHttp.responseText);
	}
	else
	{
		response = doc.documentElement.firstChild.text;
		
		/* MsXml modif */
		responseDocument = new ActiveXObject("Msxml2.DOMDocument");
		
		responseDocument.loadXML(response);
		
		if (responseDocument.parseError.errorCode != 0 || responseDocument.xml == '')
		{
			SiteNote.Debug.error('[HierarchyManager] Unable to retrieve read response');
		}
		else
		{
			status = responseDocument.documentElement.firstChild;
			
			if (status.text == 'succeed')
			{
				return status.nextSibling.text;
			}
			else
			{
				return null;
			}
		}
	}

}

HierarchyManager.prototype.GetNodeId = function (url)
{
	var post;
	var doc;
	var response;
	var responseDocument;
	var status;

	post = "url=" + encodeURIComponent(url);

	this.xmlHttp.Open("POST", this.service + '/GetNodeId', false);
	this.xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	this.xmlHttp.Send(post);

	doc = this.xmlHttp.responseXML;

	if (doc.parseError.errorCode != 0 || doc.xml == '')
	{
		SiteNote.Debug.error('[HierarchyManager][GetNodeId] Unable to execute request : ' + this.xmlHttp.responseText);
	}
	else
	{
		response = doc.documentElement.firstChild.text;
		
		/* MsXml modif */
		responseDocument = new ActiveXObject("Msxml2.DOMDocument");
		
		responseDocument.loadXML(response);
		
		if (responseDocument.parseError.errorCode != 0 || responseDocument.xml == '')
		{
			SiteNote.Debug.error('[HierarchyManager][GetNodeId] Unable to retrieve read response');
		}
		else
		{
			status = responseDocument.documentElement.firstChild;
			
			if (status.text == 'succeed')
			{
				return status.nextSibling.text;
			}
			else
			{
				return null;
			}
		}
	}

}
